
var xhr2 = new XMLHttpRequest();
var url2 = "https://localhost/planmytrip/bank_servlet.php";
var bank_connect_callback = function() {
    if (xhr2.readyState === 4) {/* request complete */
        if (xhr2.status === 200) { /* HTTP return code 200 : OK */
            var res = this.responseText;
            if (res === "OK") {
            	alert("Payment OK safe journey");
                document.cookie="departure_date=";
                document.cookie="total_price=";
                location.href = "plan_trip.php";
            } else alert("Error : "+this.responseText;);
        } else alert('communication Error');
    }
};
var bank_connect = function() {
    var full_name = document.getElementById("full_name").value,
            account_num = document.getElementById("account_num").value;
    if (full_name !== "" && account_num !== "") {
        xhr2.open("POST", url2, true);
        xhr2.onreadystatechange = bank_connect_callback;
        xhr2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xhr2.send("fullname=" + full_name + "&accountnum=" + account_num + "&token=" + token);
    } else {
        alert('Please fill all the fields of the form.');
    }
};
